﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Wimm.Common.Entities;
using Wimm.Common.Interfaces.Repositories;
using Wimm.Common.Interfaces.Services;

namespace Wimm.BusinessLogic.Services
{
    public class UserService : IUserService
    {
        private IUserRepository _userRepository;
        public UserService(IUserRepository userRepository)
        {
            _userRepository = userRepository;
        }
        public AuthenticationMode GetAuthMode()
        {
            return AuthenticationMode.Anonymus;
        }
        //
        private List<User> dummyUser = new List<User>();
        //

        public async Task<IEnumerable<User>> LoadUsers()
        {
            return await _userRepository.LoadUsers();
        }

        public async Task<bool> DoublLogin(string login)
        {
            User u = await _userRepository.FindUserByLogin(login);

            if (u == null)
            {
                return true;
            }

            return false;

        }

        public async Task<bool> DoublPassword(string password)
        {
            User u = await _userRepository.FindUserByPassword(password);

            if (u == null)
            {
                return true;
            }

            return false;
        }

        public bool Login(User user, string password)
        {
            return true;//testing
        }

        public async Task<User> InsertUser(User newUser)
        {
            return await _userRepository.InsertUser(newUser);
        }
    }
}
